package stage.manager;

import java.util.List;

import org.hibernate.*;

import stage.dao.HistoricalInfosDAO;
import stage.factory.DaoFactory;
import stage.tools.HibernateUtil;
/**
 * the service for multi historical info. 
 * @author remi liu(Liu Zhibin)
 * @version 0.5
 */
public class HistoricalInfosService {
	public List get(String hospital,String department,String isExpert,int weekday)throws Exception{
		Character h;
		if(hospital.equals("宝安区人民医院"))
			h='a';
		else if(hospital.equals("宝安区沙井人民医院"))
			h='b';
		else 
			h='c';
		Character d=(department.equals("妇科")?'a':'b');
		Boolean i=(isExpert.equals("专家号")?true:false);
		Integer w=weekday;
		
		HistoricalInfosDAO hd=(HistoricalInfosDAO)DaoFactory.instance().getDao("HistoricalInfosDAO");
		Session s=HibernateUtil.sf.getCurrentSession();
		Transaction tx=s.beginTransaction();
		System.out.print(hd.toString());
		List l=hd.get(s, h, d, i, w);
		tx.commit();
		return l;
	}
	/**
	 * һ�����㷨�ϸ�ʲô�߼������������
	 * @param hospital
	 * @param department
	 * @param isExpert
	 * @return
	 * @throws Exception
	 */
	public List getAll(String hospital,String department,String isExpert)throws Exception{
		Character h;
		if(hospital.equals("宝安区人民医院"))
			h='a';
		else if(hospital.equals("宝安区沙井人民医院"))
			h='b';
		else 
			h='c';
		Character d=(department.equals("妇科")?'a':'b');
		Boolean i=(isExpert.equals("专家号")?true:false);
		HistoricalInfosDAO hd=(HistoricalInfosDAO)DaoFactory.instance().getDao("HistoricalInfosDAO");
		Session s=HibernateUtil.sf.getCurrentSession();
		Transaction tx=s.beginTransaction();
		List l=hd.getAll(s, h, d, i);
		tx.commit();
		return l;
	}
}
